/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.kgierlicka.matrix.model;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import pl.kgierlicka.matrix.exceptions.WrongMatrixDimensionsException;

/**
 *
 * @author kgierlicka
 */
public class MatrixModel extends Matrix implements TableModel{

    public MatrixModel(Matrix m) {
        super(m);
    }

    public MatrixModel(int rowCount, int columnCount) {
        super(rowCount, columnCount);
    }
    

    
    @Override
    public String getColumnName(int i){
        return null;
    }

    
    @Override
    public Class<?> getColumnClass(int i)
    {
        ArrayList row = (ArrayList)super.getMatrix().get(0);
        return row.get(i).getClass();
    };

    @Override
    public boolean isCellEditable(int i, int i1){
        return true;
    };

    @Override
    public Object getValueAt(int i, int i1){
        ArrayList row = (ArrayList)super.getMatrix().get(i);
        return row.get(i1);
    }
            ;

    @Override
    public void setValueAt(Object o, int i, int i1){
        try {
            super.setField(i, i1, (Double)o);
        } catch (WrongMatrixDimensionsException ex) {
            Logger.getLogger(MatrixModel.class.getName()).log(Level.SEVERE, null, ex);
        }
    };

    @Override
    public void addTableModelListener(TableModelListener tl){
        
    }
            ;

    @Override
    public void removeTableModelListener(TableModelListener tl) {
        
    };

    @Override
    public int getRowCount() {
        return super.getMatrixRowCount().intValue();
    }

    @Override
    public int getColumnCount() {
        return super.getMatrixColumnCount().intValue();
    }
    
    
    
    
    
}
